# @Author   : 懒羊羊
# @File     : logout.py
# @Time     : 2024/12/11 19:21
import time

from appium import webdriver
from appium.options.common import AppiumOptions
from appium.webdriver.common.appiumby import AppiumBy

url = "http://127.0.0.1:4723/wd/hub"

options = AppiumOptions()

options.set_capability('platformName', 'Android')
options.set_capability('platformVersion', '9')
options.set_capability('deviceName', 'xxx')
options.set_capability('appPackage', 'com.kkpodcast')
options.set_capability('appActivity', 'com.kkpodcast.activity.WelcomeActivity')
options.set_capability('noReset', True)
# options.set_capability('browserName', 'Browser')
# options.set_capability('chromedriverExecutable', r'D:\python-workspace\python-lizhe\python-common-trl\appAuto\chromedriver.exe')

driver = webdriver.Remote(url, options=options)

time.sleep(5)

# 输入手机号
driver.find_element(AppiumBy.ID,"com.kkpodcast:id/input_phone_et").send_keys("19286685595")
# 输入密码
driver.find_element(AppiumBy.ID, "com.kkpodcast:id/input_password_et").send_keys("123456789")

time.sleep(2)
# 勾选同意协议
driver.find_element(AppiumBy.CLASS_NAME, "android.widget.CheckBox").click()

# 点击登录
driver.find_element(AppiumBy.XPATH, '//*[@resource-id="com.kkpodcast:id/login_tv"]').click()

time.sleep(3)

# 点击我的
driver.find_element(AppiumBy.ID, 'com.kkpodcast:id/mine_rb').click()
time.sleep(2)
# 点击头像
driver.find_element(AppiumBy.ID, 'com.kkpodcast:id/header_iv').click()
time.sleep(2)
# 点击退出登录
driver.find_element(AppiumBy.ID, 'com.kkpodcast:id/login_out_tv').click()
